/*
 * @Author: your name
 * @Date: 2021-10-23 19:43:40
 * @LastEditTime: 2021-10-23 19:43:41
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \luogu\动态规划\模板问题\P1020 导弹拦截\pass.cpp
 */
#include<iostream>
using namespace std;
#include<algorithm>

int a[100010];

int up[100010];
int down[100010];

int main(){
    int n = 0;
    while(cin >> a[++n]); n--;

    //最长上升子序列 严格 
    up[0] = -1;
    int len1 = 0;
    for(int i=1; i<=n; i++){
        //二分
        int l=0,r=len1;
        while(l<r){
            int m = (l+r+1) >> 1;
            if(up[m] < a[i]) l=m;
            else r=m-1;
        }
        len1 = max(len1,l+1);
        up[l+1] = a[i];
    }
    // cout << len1 << endl;

    //最长下降子序列 非严格
    down[0] = 1e7;
    int len2 = 0;
    for(int i=1; i<=n; i++){
        int l=0,r=len2;
        while(l < r){
            int m = (l+r+1) >> 1;
            if(down[m] >= a[i]) l=m;
            else r=m-1;
        }
        len2 = max(len2,l+1);
        down[l+1] = a[i];
    }
    cout << len2 << endl;
    cout << len1 << endl;
}